from django.http import Http404
from django.shortcuts import render, redirect
from django.urls import reverse
from django.views.generic import View

# Create your views here.
from gustbook.forms import GustBookForm


class GustBookView(View):
    def post(self, request):
        form = GustBookForm(request.POST)
        if form.is_valid():
            try:
                form.save()
            except Exception as e:
                raise Http404
        # 重定向到留言板
        return redirect(reverse('myblog:blog_gustbook'))
